<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <!-- 1. 安装 vue-router 路由模块 -->
    <script src="https://cdn.bootcss.com/vue-router/3.1.3/vue-router.js"></script>
</head>

<body>
    <div id="app">
        <com1 :parentmsg="msg" @func="getMsgFormSon"></com1>
    </div>

    <template id="tmpl">
        <div>
            <input type="button" value="给父组件传消息" @click="sendMsg">
            <h1>我是小儿子-------{{parentmsg}}</h1>
        </div>

    </template>

    <script>
        var com1 = {
            template: '#tmpl',
            props: ['parentmsg'],
            data() {
                return {
                    msg: '孝敬老爸 10000'
                }
            },
            methods: {
                sendMsg() {
                    this.$emit('func', this.msg)
                }
            }
        }

        var vm = new Vue({
            el: '#app',
            data: {
                msg: '爹有一百元',
                msgFormSon: ''
            },
            methods: {
                getMsgFormSon(data) {
                    this.msgFormSon = data
                }
            },
            components: {
                com1
            }
        })
    </script>
</body>

</html>